package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrdersPageVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author iTaotao
 * @version 1.0
 * @date 2023/08/04 16:33:17
 */
@Mapper
public interface AdminOrderMapper {


    /**
     * 订单分页
     *
     * @param
     * @return {@link Page}<{@link OrdersPageVO}>
     */


    @Select("select count(*) from orders where status =2")
    Integer selectstatusByTwo();

    @Select("select count(*) from orders where status =3")
    Integer selectStatusByThree();

    @Select("select count(*) from orders where status =4")
    Integer selectstatusByFor();

    /**
     * 分页
     *
     * @param orders 订单
     * @return {@link Page}<{@link Orders}>
     */
    Page<Orders> selectPage(Orders orders);

    /**
     * 取消订单
     *
     * @param orders 订单
     */
    @Update("update orders set status = 6 , cancel_reason = #{cancelReason} ,  cancel_time = #{cancelTime} where id = #{id}")
    void cancelOrder(Orders orders);

    @Update("update orders set status = 3 where id = #{id}")
    void updateOrderStatus(Orders orders);

    /**
     * 拒绝订单
     *
     * @param orders 订单
     */
    @Update("update orders set status = 7 , rejection_reason = #{rejectionReason} where id = #{id}")
    void rejectionOrder(Orders orders);

    /**
     * 派送订单
     *
     * @param id id
     */
    @Update("update orders set status = 4 where id = #{id} ")
    void DeliveryOrder(Long id);

    /**
     * 完整订单
     *
     * @param
     */
    @Update("update orders set status = 5 , delivery_time = #{deliveryTime} where id = #{id} ")
    void completeOrder(Orders orders);

    /**
     * 选择订单细节id
     *
     * @param id id
     * @return {@link List}<{@link OrderDetail}>
     */
    @Select("select * from order_detail where order_id = #{id}")
    List<OrderDetail> selectOrderDetailById(Long id);

    @Select("select * from  orders where id = #{id}")
    Orders selectOrderById(Long id);
}
